<?php 
			$breadcrumb = get_breadcrumb();
			global $post;
		 	the_post(); 
		 	$post_id =  get_the_ID();
		 	$permalink = get_permalink($post_id);
			$title = get_the_title($post_id);
			$content = $post->post_content;
			$content = apply_filters('the_content', $content);
			$parent_id  = ($post->post_parent)? ($post->post_parent):$post_id;
			$parent_title = get_the_title($parent_id);
			$parent_permalink = get_permalink($parent_id);
?>
<?php get_header();?>

	<div id="container" class="container">
		<div id="content" class="content bg_white" role="main">
			<div class = "breadcrumb">
					<?php echo $breadcrumb;?>	
			</div>		
			<div class = "w100 fl line-aaa"></div>		
			
			<div class = "page-center">
			
				<div class = "sidebar-left">
					<?php 
						$args = array(	
  								'post_type' 	=> 'page',
								'post_status'	=> 'publish',
								'post_parent'	=>	$parent_id,
								'orderby' 		=> 'menu_order',
								'order'			=> 'ASC'
							 );
						$the_query = new WP_Query( $args );
						
						if ($the_query->have_posts()) {
					
					?>
					
					<div class = "page_parent"><a href= "<?php echo $parent_permalink;?>"><?php echo strtoupper($parent_title);?></a></div>
					<div class = "page_child_menu">
						<ul>
					<?php 
						while ($the_query->have_posts()) {
							$the_query->the_post();
							$child_post_id =  get_the_ID();
							$child_permalink = get_permalink($child_post_id);
							$child_title = get_the_title($child_post_id);
					?>
						<li><a href="<?php echo $child_permalink;?>"><?php echo $child_title;?></a></li>
						<?php }?>
						</ul>
					</div>
					
					<?php }?>
				</div>
				<div class = "center-with-sides">	
						<div class ="page_detail">
							<div class ="page_title">
								<?php echo $title;?>
							</div>
							<?php 				
								$stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
								switch ( $stage ) {
								case 'validate_form':
									validate_allowance_form();
									break;
								case 'default':
								default :
									?>
									<div class ="page_content">
									<?php echo $content; ?>
									</div>
									<div class ="clr"></div>
									
									<?php 
									allowance_form();
									break;			
								}						
							?>
						</div>					
				</div>
			</div><!-- .page-center -->
			<div class = "sidebar-right">
					<div class = "page_right">
							<?php get_sidebar('right');?>
					</div>
			</div>
				
		</div><!-- #content -->
	</div><!-- #container -->


<?php get_footer(); ?>
